
# Balance 
library(designmatch)
library(foreign)
library(xtable)

rm(list=ls())

data <- read.dta("./data/did_1950.dta")
data <- data[order(data$treat, decreasing = TRUE), ]

# Matrix of covariates
X_mat = cbind(data$percentblack*100, data$blackpct20inschool)
                         
bal_names <- c("Percent Black", "Percent Black in School")

t_ind <- data$treat			  	  
t_id_pre <- seq(1, sum(data$treat))
c_id_pre <- seq(sum(data$treat)+1, nrow(data))

bal.tab.pre <- meantab(X_mat, t_ind, t_id_pre, c_id_pre,
                       digits = 2)
bal.tab.pre <- bal.tab.pre[,-1:-3]

rownames(bal.tab.pre) <- bal_names			  
bal.tab.pre
xtable(bal.tab.pre)

table(data$treat)